#ifndef _PANEL_H_
#define _PANEL_H_

#pragma warning ( disable: 4786 )
#include <deque>
#include <functional>

#include <interfacelib/window/window.h>
#include <utillib/util/UserFunctionManager.h>
#include <interfacelib/Window/tooltip.h>

namespace interfacelib
{
	namespace Frame
	{
		class Frame;
	};
	namespace Window
	{
		class Panel : public utillib::util::UserFunctionManager, public Window
		{
		private:
			typedef std::deque < Window * > dequeWindow;
		public:
			Panel();
			virtual ~Panel();

		public:
			virtual bool add( Window *window );
			void remove( Window *window, bool deleteFlag = true  );

			virtual void draw( Window *checkWindow = NULL );
			virtual void preTranslateMessage( MSG *msg );
			
			virtual void onButtonClick( Window *window ){};
			
			Window *getWindowAtPt( LONG x, LONG y );

			void setTopWindow( Window *window );
			Window *getTopWindow(){ return ( m_focusWindow ); };
			Window *getCaptureWindow(){ return ( m_captureWindow ); };

			bool isTopWindow( interfacelib::Window::Window *window );
			void clear( bool deleteFlag = true );
			virtual void setAlphaValue( BYTE a );
			virtual void onMouseOut( LONG x, LONG y )
			{
				Window::onMouseOut( x, y );
				if ( m_captureWindow ) m_captureWindow->onMouseOut( x, y );
				if ( m_lastOverWindow ) m_lastOverWindow->onMouseOut( x, y );
			};
			interfacelib::Window::Panel *getSaveModalDialog( bool &isDelete );
			void setSaveModalDialog( interfacelib::Window::Panel *dialog , bool isDelete );

			virtual void initialize();

			void setTooltip( int x, int y, char *tooltip );
			virtual bool createTooltip( char *image , int marginX, int marginY );

			virtual bool onESCKeyDown(){ return ( false );};
			virtual bool onEnterKeyDown(){ return ( false );};
		protected:
			Window *m_captureWindow;
			Window *m_focusWindow;
			Window *m_lastOverWindow;
			dequeWindow m_windowList;

		private:
			Panel *m_saveModalDialog;
			bool m_isDeleteSaveModalDialog;

			friend interfacelib::Frame::Frame;

			interfacelib::Window::Tooltip m_tooltip;

			virtual void buttonNotify( interfacelib::Window::Window *window );

#ifdef		_DEBUG
		public:
			virtual void setDisplayPosition( bool mode );
#endif
		};
		
	}
}

#endif